package com.yykj.hospital.server.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yykj.common.service.RedisService;
import com.yykj.common.vo.PageData;
import com.yykj.common.vo.ResultVO;
import com.yykj.hospital.client.dto.HospitalDTO;
import com.yykj.hospital.client.dto.HospitalSettingDTO;
import com.yykj.hospital.client.form.HospitalEditForm;
import com.yykj.hospital.client.form.HospitalListForm;
import com.yykj.hospital.client.form.HospitalSettingForm;
import com.yykj.hospital.server.service.HospitalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *
 * Created by chendg on 2021/9/8 0008.
 */
@Slf4j
@RestController
@RequestMapping("/api/backstage/hospital")
@Api(tags = "医院后台相关接口")
@SuppressWarnings(value = "unchecked")
public class HospitalBackstageController {


	@GetMapping("/info/{id}")
	@ApiOperation(value = "医院信息" )
	public ResultVO<HospitalDTO> info(@PathVariable(name = "id") Integer id) {
		return ResultVO.success(hospitalService.getHospitalInfo(id));
	}

	@PutMapping("/edit")
	@ApiOperation(value = "医院修改" )
	@ApiOperationSupport(ignoreParameters = { "name" })
	public ResultVO<HospitalDTO> editHospital(
			@RequestBody HospitalEditForm hospitalEditForm) {
		return ResultVO.success(hospitalService.editHospital(hospitalEditForm));
	}

	// ==================================================================================================
	@PutMapping("/setting/add")
	@ApiOperation(value = "添加医院配置")
	public ResultVO<HospitalSettingDTO> addHospitalSetting(
			@RequestBody HospitalSettingForm hospitalSettingForm) {
		return ResultVO.success(hospitalService.addHospitalSetting(hospitalSettingForm));
	}

	@GetMapping("/setting/{hospitalId}")
	@ApiOperation(value = "获取医院配置")
	public ResultVO<HospitalSettingDTO> getHospitalSetting(
			@PathVariable(required = true, name = "hospitalId") Integer hospitalId) {
		return ResultVO.success(hospitalService.getHospitalSetting(hospitalId));
	}

	private HospitalService hospitalService;

	@Autowired
	public void setHospitalService(HospitalService hospitalService) {
		this.hospitalService = hospitalService;
	}

}
